<style>
.activity-detail{
	display: flex;
	flex-direction: column;
	width: 100%;
	padding: 32upx;
	box-sizing: border-box;
}
.ac-detail{
	
	font-size: 32upx;
}
.ac-detail img{
	max-width: 100%;
}
.btn-box{
	text-align: center;
}
.acbtn{
	display: inline-block;
	margin: 0 auto;
	margin-top: 40upx;
	padding: 0 40upx;
	line-height: 2.2;
	font-size: 34upx;
}
</style>
<template>
	<view class="activity-detail">
		<div class="ac-detail" v-html="activity.content">
			
		</div>
		<div class="btn-box">
			<button class="acbtn" type="primary" @click="getCoupon" v-if="activity.type==1">领取点金券</button>
			<button class="acbtn" type="primary" @click="toStore" v-if="activity.type==2">推荐好店 > </button>
			<button class="acbtn" type="primary" @click="toLease" v-if="activity.type==3">租好物 > </button>
			<button class="acbtn" type="primary" @click="toGoods" v-if="activity.type==4">爆款商品 > </button>
			
		</div>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				activity:{
					
				}
			};
		},
		methods:{
			getCoupon(){
				let that = this
				let uid = this.$store.state.userInfo.uid
				console.log(uid);
				if(!uid){
					uni.navigateTo({
					    url: '../../login/login',
					});
				}else{
					uni.request({
						url: that.httpUrl + 'userCoupon/getCoupon',
						method: 'POST',
						header: {
							'content-type': 'application/x-www-form-urlencoded'
						},
						data: {
							uid: uid,
							cid: that.activity.busId
						},
						success: (res) => {
							console.log(res)
							if (res.data.code == 1) {
								uni.showToast({
									title: '领取成功',
									icon: 'none',
									mask: true
								})
								// that.activity.type = 0
							} else {
								uni.showToast({
									title: res.data.msg,
									icon: 'none',
									mask: true
								})
							}
						}
					})
				}
			},
			toStore(){
				uni.navigateTo({
					url:'../../user/payStore/storeInfo?bid='+this.activity.busId
				})
			},
			toLease(){
				uni.navigateTo({
					url:'../../storeList/storeDetail/storeDetail?bid='+this.activity.busId
				})
			},
			toGoods(){
				uni.navigateTo({
					url:'../../shop/shopGoods/shopGoods?gid='+this.activity.busId
				})
			},
			getDetail(){
				let that = this
				uni.request({
					url: that.httpUrl + 'activity/list4Page',
					method: 'POST',
					header: {
						'content-type': 'application/x-www-form-urlencoded'
					},
					data: {
						id:that.id,
						pageNum: 1,
						pageSize: 1
					},
					success: (res) => {
						console.log(res)
						if (res.data.code == 1) {
							that.activity = res.data.data.data[0]
							console.log(that.activity);
						} else {
							uni.showToast({
								title: res.data.msg,
								icon: 'none',
								mask: true
							})
						}
					}
				})
			}
		},
		onLoad(options) {
			console.log(options);
			this.id = options.id
			this.getDetail()
// 			console.log(this.id);
		}
	}
</script>
